from lib.ZLabel import ZLabel
from lib.ZPanel import ZPanel
from lib.res.glo import SRC


class Barket ( ZPanel ) :
	def __init__ ( self , father ) :
		super ( Barket , self ).__init__ ( father , background_url = SRC [ 'image' ] [ 'baket' ] ,
		                                   size = [ 492 , 600 ] )
		self._create ( )

	def _create ( self ) :
		super ( Barket , self ).__init__ ( self.father , background_url = SRC [ 'image' ] [ 'baket' ] ,
		                                   size = [ 492 , 600 ] )
		from resource.ui.btns import _ItemBtn_Barket
		for x in self.children :
			if isinstance ( x , _ItemBtn_Barket ) :
				self.children.remove ( x )
		from resource.ui.sces import players
		self.items = players [ 0 ].item
		for key , item in enumerate ( self.items ) :
			btn = _ItemBtn_Barket ( self , item )
			btn._pos = 60 + 82 * key , 60
			if int ( item [ 'num' ] ) > 1 :
				btn._add ( ZLabel ( btn , str ( item [ 'num' ] ) , btn._size ) )
			self._add ( btn )
